package cn.market.web.action.ad;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.stereotype.Controller;

import cn.market.bean.PageView;
import cn.market.bean.QueryResult;
import cn.market.bean.ad.HtmlModule;
import cn.market.service.ad.HtmlModulService;
import cn.market.utils.Log;
import cn.market.web.formbean.ad.HtmlModuleForm;
@Controller("/control/ad/htmlmodule/list")
public class HtmlModuleAction extends Action {
	private String TAG = "HtmlModuleAction";
	@Resource
	private HtmlModulService htmlModulService;
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String methodName = "execute() ";
		Log.println(TAG, methodName);
		HtmlModuleForm formbean  = (HtmlModuleForm) form;
		
		PageView<HtmlModule> page = new PageView<HtmlModule>(12,formbean.getPage());
		
		List<Object> params = new ArrayList<Object>();
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String,String>();
		
		String where = "";
		QueryResult<HtmlModule> qr = htmlModulService.getAllHtmlModules(where, page.getFirstResult(), page.getMaxresult(), params.toArray(), orderby);
		page.setQueryResult(qr);
		request.setAttribute("pageView", page);
		return mapping.findForward("list");
	}
}
